﻿/*======================================================================
== Copyright : BlueCurve (c)
== Licence   : Gnu/GPL v2.x
== Author    : Teddy Albina
== Email     : bluecurveteam@gmail.com
== Web site  : http://www.codeplex.com/BlueCurve
========================================================================*/
using System.Collections.Generic;
using System.ServiceModel;
using BlueCurve.IndexationContract;
using System;
using System.Collections;

namespace BlueCurve.IRemoteOperations
{
    /// <summary>
    /// Interface de base
    /// </summary>
    [ServiceContract]
    public interface IRemoteOperationsBase
    {
        [OperationContract(IsOneWay = true)]
        void StopApplication();
        [OperationContract(IsOneWay = true)]
        void RestartApplication();
    }


    /// <summary>
    /// Interface pour la recherche et l'indexation
    /// </summary>
    [ServiceContract(SessionMode = SessionMode.Required)]
    public interface IRemoteIndexation : IRemoteOperationsBase
    {
        [OperationContract(Name = "Search", IsOneWay = false, IsInitiating = true, IsTerminating = true)]
        List<SearchContract.SearchData> Search(SearchContract.SearchQuery Querydata);
        [OperationContract(Name = "Searchxml", IsOneWay = false, IsInitiating = true, IsTerminating = true)]
        string Search(SearchContract.SearchQuery Querydata, bool e);



        [OperationContract(IsOneWay = false, IsInitiating = false, IsTerminating = true)]
        bool IndexOperation(IndexationData data);
        [OperationContract(IsOneWay = false, IsInitiating = false, IsTerminating = true)]
        int IndexCount();
        [OperationContract(IsOneWay = true, IsInitiating = true, IsTerminating = false)]
        void BackupMode();
        [OperationContract(IsOneWay = false, IsInitiating = false, IsTerminating = true)]
        SearchContract.UpdateMetaData GetMetaDataForUpdate(string path);
    }

    /// <summary>
    /// Fonctions qu'appel les web crawler pour avoir de nouveaux set de données à télécharger
    /// </summary>
    [ServiceContract(SessionMode=SessionMode.Required)]
    public interface IWebScheduler : IRemoteOperationsBase
    {
        [OperationContract(IsOneWay = true, IsInitiating = true, IsTerminating = false)] 
        void SetPriority(string key, int priority);
        [OperationContract(IsOneWay = true, IsInitiating = true, IsTerminating = false)] 
        void ChangeHostWaitTime(int waitime);
        [OperationContract(IsOneWay = true, IsInitiating = true, IsTerminating = false)] 
        void LinkToUpdate(string links);
        [OperationContract(IsOneWay = false, IsInitiating = false, IsTerminating = true)] 
        string SendQueue();
        [OperationContract(IsOneWay = false, IsInitiating = false, IsTerminating = true)] 
        int GetPriority(string key);
        [OperationContract(IsOneWay = false, IsInitiating = false, IsTerminating = true)] 
        string GetAllPriority();
    }




    /// <summary>
    /// Contrat pour le repository
    /// </summary>
    [ServiceContract(SessionMode=SessionMode.Required)]
    public interface IRepository : IRemoteOperationsBase
    {
        [OperationContract(IsOneWay = true, IsInitiating=true, IsTerminating=false)]
        void AddFile(string path, string typeoffile);
        [OperationContract(IsOneWay = true, IsInitiating = true, IsTerminating = false)]
        void AddFileToSchedule(string path);
        [OperationContract(IsOneWay = true, IsInitiating = true, IsTerminating = false)]
        void DeleteFile(string path);
        [OperationContract(IsOneWay = true, IsInitiating = true, IsTerminating = false)]
        void AddParsableFile(string typeoffile);
        [OperationContract(IsOneWay=false, IsInitiating=false, IsTerminating=true)]
        string GetFileToIndex();
        [OperationContract(IsOneWay = false, IsInitiating = false, IsTerminating = true)]
        string GetFileToParse();
        [OperationContract(IsOneWay = false, IsInitiating = false, IsTerminating = true)]
        string GetFileToSchedule();
        [OperationContract(IsOneWay = false, IsInitiating = false, IsTerminating = true)]
        List<string> GetListFilesToParse(int n);
        [OperationContract(IsOneWay = false, IsInitiating = false, IsTerminating = true)]
        List<string> GetListFilesToIndex(int n);
    }




    /// <summary>
    /// Contrat pour l'indexeur
    /// </summary>
    [ServiceContract]
    public interface IIndexer : IRemoteOperationsBase
    {
        [OperationContract]
        void ReloadAddins();
    }



    /// <summary>
    /// Contrat pour le serveur de log
    /// </summary>
    [ServiceContract(SessionMode=SessionMode.Required)]
    public interface ILog
    {
        [OperationContract(IsInitiating = true, IsTerminating = false, IsOneWay = true)]
        void Log(string message, string stacktrace, string source);
    }
}